<?php

namespace catchAdmin\pc\controller;

use catcher\base\CatchRequest as Request;
use catcher\CatchResponse;
use catcher\base\CatchController;
use catchAdmin\pc\model\Need as NeedProjectModel;
use think\Response;

class NeedProject extends CatchController
{

    protected $needProjectModel;


    /**
     *
     * @time 2025/09/17 10:37
     * @param NeedProjectModel $needProjectModel
     * @return mixed
     */
    public function __construct(NeedProjectModel $needProjectModel)
    {
        $this->needProjectModel = $needProjectModel;
    }


    /**
     *
     * @time 2025/09/17 10:37
     * @return Response
     */
    public function index(Request $request): Response
    {
        $param = $request->param();
        $param['company_type'] = 2;

        return CatchResponse::successPcList($this->needProjectModel->indexData($param));
    }


    /**
     *
     * @time 2025/09/17 10:37
     * @param Request $request
     * @return Response
     */
    public function save(Request $request): Response
    {
        return CatchResponse::success($this->needProjectModel->storeBy($request->post()));
    }


    /**
     *
     * @time 2025/09/17 10:37
     * @param $id
     * @return Response
     */
    public function read($id): Response
    {
        return CatchResponse::success($this->needProjectModel->findBy($id));
    }


    /**
     *
     * @time 2025/09/17 10:37
     * @param $id
     * @param Request $request
     * @return Response
     */
    public function update($id, Request $request): Response
    {
        return CatchResponse::success($this->needProjectModel->updateBy($id, $request->post()));
    }


    /**
     *
     * @time 2025/09/17 10:37
     * @param $id
     * @return Response
     */
    public function delete($id): Response
    {
        return CatchResponse::success($this->needProjectModel->deleteBy($id));
    }
}
